import React,{useState} from "react";

interface globalData {
    pageTitle: string | null,
}

const DefaultGlobalData: globalData={
    pageTitle: null,
}

export const globalContext = React.createContext(DefaultGlobalData)
export const setSteteContext = React.createContext<React.Dispatch<React.SetStateAction<globalData>> | undefined>(undefined);

export const GlobalStateProvider: React.FC = (props) => {
    const [state, setState] = useState(DefaultGlobalData)

    return(
        <globalContext.Provider value={state}>
            <setSteteContext.Provider value={setState}>
                {props.children}
            </setSteteContext.Provider>
        </globalContext.Provider>
    )
}